$OpenBSD: patch-Makefile_in,v 1.3 2016/03/10 21:58:51 naddy Exp $
--- Makefile.in.orig	Thu Nov 26 17:03:29 1998
+++ Makefile.in	Thu Mar 10 21:53:37 2016
@@ -15,11 +15,13 @@ CFLAGS        = $(OPTIMIZE) $(EXTRA_CFLAGS)
 CPPFLAGS      = $(INCLUDE_DIRS) $(DEFINES)
 
 # Installation directories (and install program)
+DESTDIR         = 
+
 prefix          = @prefix@
 exec_prefix     = @exec_prefix@
 INSTALL_INCLUDE = @includedir@
 INSTALL_LIBRARY = @libdir@
-INSTALL         = @INSTALL@
+INSTALL_DATA    = @INSTALL_DATA@
 
 # Other miscellaneous programs
 AR            = @AR@
@@ -37,6 +39,7 @@ DITHER_SRC    = fs2.c fs2fast.c fs4.c hybrid.c hybride
 		mono.c ordered.c ordered2.c mb_ordered.c
 LIBSRC        = @libsrc@
 LIBOBJ        = @libobj@
+SHLIBOBJ      = $(LIBOBJ:.o=.so)
 
 
 # Other files of interest
@@ -46,15 +49,20 @@ SHLIB         = libmpeg.so
 HEADER        = mpeg.h
 EXTRAS        = @extras@
 
+PICFLAG       = -fpic
+
+.SUFFIXES: .o .so
+
 # Implicit targets
 .c.o:
 		$(CC) -c $(CFLAGS) $(CPPFLAGS) $<
 
+.c.so:
+		$(CC) -c $(CFLAGS) $(CPPFLAGS) $(PICFLAG) $< -o $@
 
+
 # Library/cleanup targets: 
 
-all:		lib $(EXTRAS)
-
 lib:		$(LIBRARY)
 
 shlib:          $(SHLIB)
@@ -63,17 +71,19 @@ $(LIBRARY):	$(LIBOBJ)
 		$(AR) $(ARFLAGS) $(LIBRARY) $(LIBOBJ)
 		$(RANLIB) $(LIBRARY)
 
-$(SHLIB):	$(LIBOBJ)
-		$(CC) -shared -o $(SHLIB) $(LIBOBJ)
+$(SHLIB):	$(SHLIBOBJ)
+		$(CC) -shared $(PICFLAG) -o $(SHLIB) $(SHLIBOBJ)
 
-install:	$(LIBRARY)
-		$(INSTALL) -d $(INSTALL_INCLUDE) $(INSTALL_LIBRARY)
-		$(INSTALL) -m 0644 $(HEADER) $(INSTALL_INCLUDE)/$(HEADER)
-		$(INSTALL) -m 0644 $(LIBRARY) $(INSTALL_LIBRARY)/$(LIBRARY)
-		@if test -f $(SHLIB) ; then echo "warning: $(SHLIB) *not* installed (installing shared libraries is too system-specific)" ; fi
+all:		lib shlib $(EXTRAS)
+install:	$(LIBRARY) $(SHLIB)
+		$(INSTALL_DATA) $(HEADER) $(DESTDIR)$(INSTALL_INCLUDE)
+		$(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(INSTALL_LIBRARY)
+		@if [ -f $(SHLIB) ]; then \
+		   $(INSTALL_DATA) $(SHLIB) $(DESTDIR)$(INSTALL_LIBRARY); \
+		fi
 
 clean:
-		rm -f $(LIBRARY) $(EXTRAS) $(LIBOBJ) core
+		rm -f $(LIBRARY) $(SHLIB) $(EXTRAS) $(LIBOBJ) $(SHLIBOBJ) core
 		cd extras && $(MAKE) clean
 
 distclean:	clean
